package net.homelinux.chaoswg.io.renga.core.gui.operations.reader;

import net.homelinux.chaoswg.io.higherorderfunctions.AbstractUnaryFunction;
import net.homelinux.chaoswg.io.higherorderfunctions.UnaryFunction;
import net.homelinux.chaoswg.io.renga.core.gui.operations.FunctionInputOperation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.Operation;

import org.jdom.Element;

public class FunctionInputOperationReader extends AbstractUnaryFunction<Operation, Element> implements UnaryFunction<Operation, Element>, OperationReader {

    public Operation apply(final Element arg0) throws IllegalArgumentException {
        final FunctionInputOperation fio = new FunctionInputOperation();
        
        fio.setInitialValue(arg0.getChildText("initialValue"));
        fio.setIsInputNumber(Integer.parseInt( arg0.getChildText("inputNumber")) );
        
        final CommonOperationReader cor = new CommonOperationReader ();
        cor.apply(fio, arg0);
        
        return fio;
    }
}
